import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.*;
import java.util.Scanner;

//数据来源于键盘录入，直到输入的数据是886，发送数据结束
public class UDP_sent_Demo {
    public static void main(String[] args) throws IOException {
        DatagramSocket datagramSocket = new DatagramSocket();
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        System.out.println("Please input your data : ");
        String line ;
        while((line = bufferedReader.readLine()) != null){
            if(line.equals("886"))
                break;
            byte[] bys = line.getBytes();
            DatagramPacket datagramPacket = new DatagramPacket(bys,bys.length, InetAddress.getByName("192.168.191.1"),15000);
            datagramSocket.send(datagramPacket);
        }
        bufferedReader.close();
        datagramSocket.close();
    }
}
